﻿

Shop = new function() {
    this.InitializeAccordionClick = function(obj, type) {
        itemClicked = $(obj).parent().children('div')[0];
        if (type == 'category') {
            $.get("/categories", function(data) {
                $(itemClicked).html(data);
                Shop.Accordion(obj);
            });
        } else if (type == 'designer') {
            $.get("/designers", function(data) {
                $(itemClicked).html(data);
                Shop.Accordion(obj);
            });
        }
    }

    this.Accordion = function(obj) {
        siblings = $(obj).parent().siblings('li');
        itemClicked = $(obj).parent().children('div')[0];
        $(itemClicked).slideDown('fast', function() {
            $($(siblings).children('div')[0]).slideUp('fast');
        });
    }

    this.CheckCurrent = function() {
        $.post("/GetCurrentContext", function(data) {
            var anchors = $("#leftMenu li").children('a');
            if (data == 1) {
                $(anchors[0]).click();
            } else if (data == 2) {
                $(anchors[1]).click();
            } else {
                //Search
            }
        });
    }

    this.Onload = function() {
        Shop.CheckCurrent();
    }
}

Cart = new function() {
    this.Locked = false;
    this.AddToCart = function(idProduct, quantity) {
    $.get("/cart/add/" + idProduct + "," + quantity, function(resp) {            
                alert(resp);            
        });
    }
}